<template>
  <div id="app">
    <h1>父组件</h1>
    <Son></Son>
  </div>
</template>

<script>
import Son from "./components/Son";

export default {
  name: "App",
  data() {
    return {
      name1: "js",
      name2: "css",
      name3: "html",
      data_arr: []
    };
  },
  components: {
    Son
  },
  /* mounted() {
    const url = "https://api.github.com/search/repositories?q=v&sort=stars";
    // 发送异步请求
    this.$http
      .get(url)
      .then(response => {
        console.log(response);
        this.data_arr = response.data.items;
      })
      .catch(err => {
        console.log(err);
      });
  } ,*/
  async mounted() {
    const url = "https://api.github.com/search/repositories?q=v&sort=stars";
    // 处理异常
    try {
      let response = await this.$http.get(url);
      console.log(response);
    } catch (err) {
      // 处理失败情况
      console.log(err);
    }
  },
  methods: {}
};
</script>

<style></style>
